<template>
	<view class="mainpadding2">
		<view class="ffffff mainpadding_top flexbetween radius">
			<view class="titletext hei_text bold">找回密码手机号</view>
			<input type="number"placeholder="请输入" style="text-align: right;" class="hei_text main_size bold" v-model="bind_tel">
		</view>
		<view class="posibottom mainpadding" style="bottom: 0;">
			<view class="submitbtn" @click="submit">确认修改</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				bind_tel:"",
			}
		},
		methods: {
			isMobile(value) {
				let a = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value); 
				return a;
			},
			submit(){
				if (this.bind_tel=="") {
					httpRequest.toast("请输入找回密码手机号")
					return false
				}
				if(!this.isMobile(this.bind_tel)){
					httpRequest.toast("手机号码格式错误!")
					return;
				}
				httpRequest.request('/api/user/changetel', 'POST', {
					bind_tel: this.bind_tel,
				}).then(res => {
					if (res.code == 1) {
						httpRequest.toast('更改成功');
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					} else {
						httpRequest.toast(res.msg);
					}
				})
			}
		}
	}
</script>

<style>

</style>
